x86 hvm: suspend platform timer emulation while its IRQ is masked
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 16 Sep 2009 08:30:41 +0000 (09:30 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 16 Sep 2009 08:30:41 +0000 (09:30 +0100)
commit71708b1966462eeac3a3a2bc1a74086b2b25b62c
tree8a87d5408a4492abd3cb55694fe20ef9c622f630
parent057958b0ab83fe767397a7ef896b4e6ed63529d5
x86 hvm: suspend platform timer emulation while its IRQ is masked

This patch gets rid of a timer which IRQ is masked from vcpu's timer
list. It reduces the overhead of VM EXIT and context switch of vm.

Also fixes a potential bug.
(1) VCPU#0: mask the IRQ of a timer. (ex. vioapic.redir[2].mask=1)
(2) VCPU#1: pt_timer_fn() is invoked by expiration of the timer.
(3) VCPU#1: pt_update_irq() is called but does nothing by
pt_irq_masked()==1.
(4) VCPU#1: sleep by halt.
(5) VCPU#0: unmask the IRQ of the timer.
After that, no one wakes up the VCPU#1.

IRQ of ISA is masked by:
 - PIC's IMR
 - IOAPIC's redir[0]
 - IOAPIC's redir[N].mask
 - LAPIC's LVT0
 - LAPIC enabled/disabled

IRQ of LAPIC timer is masked by:
 - LAPIC's LVTT
 - LAPIC disabled

When above stuffs are changed, the corresponding vcpu is kicked and
suspended timer emulation is resumed.

In addition, a small bug fix in pt_adjust_global_vcpu_target().

Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>
xen/arch/x86/hvm/vioapic.c
xen/arch/x86/hvm/vlapic.c
xen/arch/x86/hvm/vpic.c
xen/arch/x86/hvm/vpt.c
xen/include/asm-x86/hvm/vpt.h